<template>
	<view class="container">
		<view class="list" v-if="list.length > 0">
			<view class="box" hover-class="hoverBox" v-for="item in list" :key="item.id" @click="goDetail(item)">
				<view class="info">
					<view class="time">{{ item.publish_time_format }}</view>
					<view class="name">{{ item.notice_title }}</view>
				</view>
				<uni-icons type="right" size="20" color="#bbb"></uni-icons>
			</view>
			<uni-pagination v-if="total > FormData.perpage" :total="total" :pageSize="FormData.perpage" :value="FormData.page" @change="changePage" />
		</view>
		<view class="empty" v-else>
			<image class="image" src="@/static/img/empty.png" mode="aspectFit"></image>
			<view class="emptyWord">暂无数据</view>
		</view>
	</view>
</template>

<script>
import api from '@/api/api';
export default {
	data() {
		return {
			total: 0,
			FormData: {
				page: 1,
				prepage: 10
			},
			list: []
		};
	},
	onShow() {
		this.getList();
	},
	onPullDownRefresh() {
		this.getList();
	},
	methods: {
		changePage(e) {
			this.FormData.page = e.current;
			this.getList();
		},
		goDetail(item) {
			uni.navigateTo({
				url: '/pages/mine/notice/detail?id=' + item.id
			});
		},
		getList() {
			api.noticeList(this.FormData).then((res) => {
				this.list = res.data.items;
				this.total = res.data.total;
				uni.stopPullDownRefresh();
			});
		}
	}
};
</script>

<style lang="scss">
.container {
	padding: 20rpx;
	.list {
		.box {
			background: #fff;
			margin-bottom: 20rpx;
			padding: 20rpx;
			border-radius: 20rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			&.hoverBox {
				background: #f1f1f1;
			}
			.time {
				font-size: 26rpx;
				color: $uni-base-color;
			}
			.name {
				font-size: 30rpx;
				color: #000;
				font-weight: bold;
				margin-top: 10rpx;
			}
		}
	}
}
</style>
